package com.team.service.impl;

import com.team.entity.DevUser;
import com.team.entity.DevUserExample;
import com.team.entity.LoginCondition;
import com.team.mapper.DevUserMapper;
import com.team.service.DevUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class DevUserServiceImpl implements DevUserService {
    @Autowired
    DevUserMapper devUserMapper;
    @Override
    public DevUser loginSelect(LoginCondition loginCondition) {
        DevUserExample devUserExample = new DevUserExample();
        DevUserExample.Criteria criteria = devUserExample.createCriteria();
        List<DevUser> devUsers1 = devUserMapper.selectByExample(devUserExample);
        if (!StringUtils.isEmpty(loginCondition.getDevCode()))
            criteria.andDevcodeEqualTo(loginCondition.getDevCode());
        if (!StringUtils.isEmpty(loginCondition.getDevPassword()))
            criteria.andDevpasswordEqualTo(loginCondition.getDevPassword());
        List<DevUser> devUsers = devUserMapper.selectByExample(devUserExample);
        if (devUsers.isEmpty()&&devUsers.size()==0)
            return null;
        else
            return devUsers.get(0);
    }
}
